/**
Date: 2025-08-13
Copyright (c) 2025 Industrial Software Feature Database
*/
import request from '@/utils/request';

// 数据采集--zip文件解析
export function preImport(data) {
  return request({
    url: '/isfd/modelManagementPart/pre/import',
    method: 'post',
    data
  });
}
//数据采集结构定义--获取机型下拉列表
export function getStructureTreeList(param) {
  return request({
    url: `/isfd/meshModelStructureDefinition/list`,
    method: 'get',
    params: param
  });
}
//数据采集结构定义-- 获取结构定义树 meshModelStructureDefinition
export function getStructureTree() {
  return request({
    url: `/isfd/meshModelStructureDefinition/tree`,
    method: 'get'
  });
}
//数据采集结构定义-- 新增树节点
export function addStructureMenu(data) {
  return request({
    url: `/isfd/meshModelStructureDefinition/add`,
    method: 'post',
    data
  });
}
//数据采集结构定义-- 修改树节点
export function updateStructureMenu(data) {
  return request({
    url: `/isfd/meshModelStructureDefinition/update`,
    method: 'post',
    data
  });
}
//数据采集结构定义-- 删除树节点
export function deleteStructureMenu(id) {
  return request({
    url: `/isfd/meshModelStructureDefinition/${id}`,
    method: 'delete'
  });
}

// 批次号查询
export function getBatchNo(params) {
  return request({
    url: `/isfd/collectBatchHistory/list`,
    method: 'get',
    params
  });
}

// 构型定义列表查询
export function getMeshModelStructureList(param) {
  return request({
    url: `/isfd/meshModelStructureDefinition/list`,
    method: 'post',
    data: param
  });
}

// 数据采集模型压缩包上传
export const uploadMeshModelZip = (data: FormData) => {
  return request({
    url: `/isfd/collect/mesh/upload/dataHandling`,
    method: 'post',
    data: data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
};

// 确认上传
export const confirmUpload = (data: any) => {
  return request({
    url: `/isfd/collect/mesh/upload/confirm`, // 确认上传
    method: 'post',
    data: data
  });
};

// 模型库 采集列表
export const getCollectList = (data: any) => {
  return request({
    url: `/isfd/collect/mesh/list`,
    method: 'post',
    data: data
  });
};

// 查看全部文件
export const getAllFileList = (params) => {
  return request({
    url: `/isfd/collect/mesh/all/files`,
    method: 'get',
    params
  });
};

/*模型对比*/
// 模型对比列表查询
export const getCompareList = (data: any) => {
  return request({
    url: `/isfd/mesh/compare/list`,
    method: 'post',
    data: data
  });
};

// 模型对比结果查询
export const getCompareDetail = (params) => {
  return request({
    url: `/isfd/mesh/compare/result/detail`,
    method: 'get',
    params
  });
};

// 新增模型对比任务
export const addCompareTask = (data: any) => {
  return request({
    url: `/isfd/mesh/compare/add`,
    method: 'post',
    data: data
  });
};

// 模型对比删除
export const deleteCompare = (id: any) => {
  return request({
    url: `/isfd/mesh/compare/${id}`,
    method: 'delete'
  });
};

// 模型文件 分类型查询
export const getModelFilesByCategory = (data) => {
  return request({
    url: `/isfd/mesh/list`, // 模型分类查询
    method: 'post',
    data
  });
};

// 自然网格模型左侧树查询
export const getNaturalMeshTree = () => {
  return request({
    url: `/isfd/mesh/tree`,
    method: 'get'
  });
};

// 自然网格模型文件预览
export const previewNaturalMesh = (params) => {
  return request({
    url: `/isfd/mesh/file/preview`,
    method: 'get',
    params
  });
};

// 自然网格模型分页查询
export const getNaturalMeshList = (data: any) => {
  return request({
    url: `/isfd/mesh/list`,
    method: 'post',
    data: data
  });
};

// bdf文件查询
export const searchNaturalMeshItem = (data) => {
  return request({
    url: `/isfd/mesh/file/search`,
    method: 'post',
    data
  });
};

// bdf文件下载
export const downloadNaturalMeshFile = (params) => {
  return request({
    url: `/isfd/mesh/file/download`,
    method: 'get',
    params
  });
};

// bdf文件重新上传
export const reuploadNaturalMeshFile = (data) => {
  return request({
    url: `/isfd/mesh/reUpload`,
    method: 'post',
    data: data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
};

// bdf文件删除
export const deleteNaturalMeshFile = (id) => {
  return request({
    url: `/isfd/mesh/${id}`,
    method: 'delete'
  });
};

// 查询模型树信息 找到根节点  -> 查询该根节点下的所有模型
export const getModelTree = (params) => {
  return request({
    url: `/isfd/databaseModel/tree/getTree`,
    method: 'get',
    params
  });
};

export const getModelList = (data: any) => {
  return request({
    url: `/isfd/databaseModel/config/list`,
    method: 'post',
    data
  });
};

// 对比文件下载
export const downloadBdfCompareResult = (params) => {
  return request({
    url: `/isfd/mesh/compare/result/report`,
    method: 'get',
    params,
    responseType: 'blob'
  });
};

// 模型对比结果导出excel的base64
export const getBdfCompareBase64Result = (params) => {
  return request({
    url: `/isfd/mesh/compare/result/base64/report`,
    method: 'get',
    params
    // responseType: 'blob'
  });
};

/* 材料库数据导入 */
// 模板下载接口
export const getModelTemplateByModelId = (params) => {
  return request({
    url: `/isfd/database/data/template`,
    method: 'get',
    params,
    responseType: 'blob'
  });
};

// 导入 - 检查
export const checkMaterialDataImport = (data: any) => {
  return request({
    url: `/isfd/database/data/import/check`,
    method: 'post',
    data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
};

// 导入 - 确认导入
export const confirmMaterialDataImport = (data: any) => {
  return request({
    url: `/isfd/database/data/import/confirm`,
    method: 'post',
    data
  });
};

// 材料库数据导入列表数据
export const getMaterialImportDataList = (data: any) => {
  return request({
    url: `/isfd/database/data/queryPageList`,
    method: 'post',
    data
  });
};

// 数据采集卡片列表
export const getDatabaseModelCardList = (params: any) => {
  return request({
    url: `/isfd/databaseModel/config/card/list`,
    method: 'get',
    params
  });
};

// 数据财力 - 点击卡片详情查看
export const getDatabaseModelCardDetail = (params: any) => {
  return request({
    url: `/isfd/databaseModel/config/card/detail`,
    method: 'get',
    params
  });
};

/** 自然网格结果库 **/
// 根据机型获取历史轮次
export function getRoundNo(params) {
  return request({
    url: `/isfd/collectRoundHistory/list`,
    method: 'get',
    params
  });
}

// 数据处理
export function handleOp2UploadData(data) {
  return request({
    url: `/isfd/collect/op2/upload/dataHandling`,
    method: 'post',
    data
  });
}
// 确认上传
export function confirmOp2Upload(data) {
  return request({
    url: `/isfd/collect/op2/upload/confirm`,
    method: 'post',
    data
  });
}

// 分片上传 - 初始化接口
export function initChunksFileUpload(data) {
  return request({
    url: `/isfd/largeFile/chunks/upload/init`,
    method: 'post',
    data
  });
}
// 分片上传 - 分片上传接口
export function op2ChunksUpload(data: any) {
  return request({
    url: `/isfd/largeFile/chunks/upload`,
    method: 'post',
    data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
}
// 分片上传 - 查询进度
export function checkOp2ChunksUploadProgress(params) {
  return request({
    url: `/isfd/largeFile/chunks/upload/check`,
    method: 'get',
    params
  });
}
// 采集结果文件 - 分页列表接口
export function getCollectOp2DataList(data) {
  return request({
    url: `/isfd/collect/op2/list`,
    method: 'post',
    data
  });
}
// 采集结果文件 && 自然网格结果库  - 左侧树
export function getOp2Tree(params) {
  return request({
    url: `/isfd/mesh/tree`,
    method: 'get',
    params
  });
}
// 采集结果文件 - 重新上传-校验接口
export function checkReupload(data) {
  return request({
    url: `/isfd/largeFile/chunks/reUpload/check`,
    method: 'post',
    data
  });
}
// 采集结果文件 - 重新上传
export function reuploadOp2Chunks(data) {
  return request({
    url: `/isfd/largeFile/chunks/reUpload`,
    method: 'post',
    data
  });
}
// 自然网格结果库 - 分页列表
export function getMeshOp2DataList(data) {
  return request({
    url: `/isfd/mesh/op2/list`,
    method: 'post',
    data
  });
}

// 自然网格结果库 - 结果文件下载
export function downloadOp2ResultFile(params) {
  return request({
    url: `/isfd/mesh/op2/file/download`,
    method: 'get',
    params,
    responseType: 'blob'
  });
}

// 库文件删除
export function deleteMeshOp2File(params) {
  return request({
    url: `/isfd/largeFile/delete`,
    method: 'get',
    params
  });
}

// 重新上传新的切片
export function op2ChunksUploadAgain(data: any) {
  return request({
    url: `/isfd/collect/op2/upload/again`,
    method: 'post',
    data
  });
}

/***********自然网格结果文件分析***************/
// 查询模型对比默认条目列表
export function getCompareDefaultItemList(params) {
  return request({
    url: `/isfd/op2/analysis/item/default/list`,
    method: 'get',
    params
  });
}

// 结果库对比条目树结构查询
export function getCompareEntriesTree(params) {
  return request({
    url: `/isfd/op2/analysis/item/tree`,
    method: 'get',
    params
  });
}

// 结果库对比 单元/节点清单上传
export function uploadCompareEntries(data) {
  return request({
    url: `/isfd/op2/analysis/upload`,
    method: 'post',
    data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
}

// 获取所有部段名称
export function getAllSectionNames(params) {
  return request({
    url: `/isfd/meshModelStructureDefinition/getAllSectionNames`,
    method: 'get',
    params
  });
}

// 根据部段名称查询机型-部段信息
export function getModelSectionInfoBySectionName(params) {
  return request({
    url: `/isfd/meshModelStructureDefinition/getModelAndSectionInfoBySectionName`,
    method: 'get',
    params
  });
}

// 模型对比任务列表查询
export function getOp2CompareTaskList(data) {
  return request({
    url: `/isfd/op2/analysis/list`,
    method: 'post',
    data
  });
}

// 模型对比结果查询
export function getOp2CompareTaskDetail(params) {
  return request({
    url: `/isfd/op2/analysis/result/detail`,
    method: 'get',
    params
  });
}

// 模型对比任务删除
export function deletOp2eCompareTask(id) {
  return request({
    url: `/isfd/op2/analysis/${id}`,
    method: 'delete'
  });
}

// 新增模型对比任务
export function addOp2CompareTask(data) {
  return request({
    url: `/isfd/op2/analysis/save`,
    method: 'post',
    data
  });
}

// 节点清单模板下载
export function downloadOp2ResultTemplate(params) {
  return request({
    url: `/isfd/op2/analysis/comparedElements/template`,
    method: 'get',
    params,
    responseType: 'blob'
  });
}

// 模型对比详情查询
export function getCompareTaskDetail(params) {
  return request({
    url: `/isfd/op2/analysis/result/report`,
    method: 'get',
    params
  });
}
// op2文件切片上传
export const uploadOp2FileChunk = (data: FormData) => {
  return request({
    url: `/isfd/largeFile/chunks/upload`,
    method: 'post',
    data: data,
    headers: {
      'Content-type': 'multipart/form-data'
    }
  });
};

// 数据导入模块文件下载
export const downloadDataImportFile = (params) => {
  return request({
    url: `/isfd/database/data/download`,
    method: 'get',
    params,
    responseType: 'blob'
  });
};

export const bdfPreview = (id) => {
  return request({
    url: `/isfd/mesh/load?_id=${id}`,
    method: 'get'
  });
};